package com.chen.Dome3Annotation;

import java.lang.reflect.Method;

public class AnnotationDome4 {
    public static void main(String[] args) {
        //认识注解的作用，模拟注解的解析器
        AnnotationDome4 ad=new AnnotationDome4();
        Class clazz=AnnotationDome4.class;
        Method[] methods=clazz.getMethods();
        for (Method method : methods) {
            //判断方法上是否有MyTest注解
            if(method.isAnnotationPresent(MyTest.class)){
                //执行方法
                try {
                    method.invoke(ad);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    public void test1() {
        System.out.println("test1");
    }
    public void test2() {
        System.out.println("test2");
    }
    public void test3() {
        System.out.println("test3");
    }
    @MyTest
    public void test4() {
        System.out.println("test4");
    }
    @MyTest
    public void test5() {
        System.out.println("test5");
    }
}
